package com.my.springboot.tuling.jvm.bean;


import com.my.springboot.tuling.jvm.gc.OOMTest;

public class User {
    private Integer id;
    private String name;

    public User() {

    }

    public User(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    protected void finalize() throws  Throwable{
        //重新与引用链上的对象建立关联，则不会被回收
        //OOMTest.list.add(this);
        System.out.println("关闭资源, id = " + id + "即将被回收");
    }
}
